home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 2,801 to 2,900 / aol-file-protocol-4400-2801-to-2900.zip / AOLDLs / C++ Files Library / HyperCuber Source / HyperCuber 2.0 Source.sit / HyperCuber 2.0 Source / CPrefsDialogDirector.cp < prev    next >
Text File  |  1994-04-05  |  4KB  |  139 lines

  1. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2. //| CPrefsDialogDirector.cp
  3. //|
  4. //| This implements the preferences dialog director
  5. //|_________________________________________________________
  6.  
  7. #include "CColorPane.h"
  8. #include "CHyperCuberDoc.h"
  9. #include "CHyperCuberPrefs.h"
  10. #include "CPrefsDialog.h"
  11. #include "CPrefsDialogDirector.h"
  12.  
  13. #include "HyperCuber Commands.h"
  14.  
  15.  
  16.  
  17. //============================ Globals ============================\\
  18.  
  19. extern CDesktop         *gDesktop;
  20. extern CHyperCuberPrefs    *gPrefs;
  21.  
  22.  
  23.  
  24. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  25. // CPrefsDialogDirector::IPrefsDialogDirector
  26. //
  27. // Purpose: Initialize the preferences dialog.
  28. //
  29. // Parameters: none
  30. //_________________________________________________________
  31.  
  32. void CPrefsDialogDirector::IPrefsDialogDirector (CDirectorOwner *aSupervisor)
  33. {
  34.  
  35. #define PREFS_WINDOW_ID    128
  36.  
  37.     CDialogDirector::IDialogDirector (aSupervisor);            //  Init superclass
  38.  
  39.     CPrefsDialog *dialog = new (CPrefsDialog);                //  Set up the prefs dialog
  40.     dialog->IPrefsDialog (PREFS_WINDOW_ID, gDesktop, this);
  41.     itsWindow = dialog;
  42.  
  43. }    //=== CPrefsDialogDirector::CPrefsDialogDirector() ===\\
  44.  
  45.  
  46.  
  47. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  48. //| CPrefsDialogDirector::DoKeyDown / CPrefsDialogDirector::DoAutoKey
  49. //|
  50. //| Purpose: These procedure handles a key down event.  Their sole purpose is to
  51. //|          prevent the keydown from getting to the Controls Director.
  52. //|
  53. //| Parameters: ignored
  54. //|______________________________________________________________________________
  55.  
  56. void    CPrefsDialogDirector::DoKeyDown(char the_char, Byte key_code, EventRecord *event)
  57. {
  58.  
  59. }    //==== CPrefsDialogDirector::DoKeyDown() ====\\
  60.  
  61.  
  62. void    CPrefsDialogDirector::DoAutoKey(char the_char, Byte key_code, EventRecord *event)
  63. {
  64.  
  65. }    //==== CPrefsDialogDirector::DoAutoKey() ====\\
  66.  
  67.  
  68.  
  69. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  70. // CPrefsDialogDirector::DoCommand
  71. //
  72. // Purpose: Handle commands for the dialog.
  73. //
  74. // Parameters: none
  75. //_________________________________________________________
  76.  
  77. void CPrefsDialogDirector::DoCommand( long aCmd)
  78. {
  79.  
  80.     switch (aCmd)
  81.     {
  82.     
  83.         case cmdDefaults:
  84.         
  85.             PrefsStruct prefs;
  86.             prefs = gPrefs->prefs;                    //  Save the current prefs
  87.  
  88.             gPrefs->SetDefaults();                    //  Set all preferences to default values
  89.             
  90.             CPrefsDialog *dialog = (CPrefsDialog *) itsWindow;            //  Change the colors
  91.             dialog->background_color_pane->SetPaneColor(&(gPrefs->prefs.background_color));
  92.             dialog->left_eye_color_pane->SetPaneColor(&(gPrefs->prefs.left_eye_color));
  93.             dialog->right_eye_color_pane->SetPaneColor(&(gPrefs->prefs.right_eye_color));
  94.  
  95.             gPrefs->prefs = prefs;                    //  Restore the current prefs
  96.  
  97.             break;
  98.     
  99.         default:
  100.             inherited::DoCommand( aCmd);
  101.             break;
  102.     }
  103.     
  104. }    //=== CPrefsDialogDirector::DoCommand ===\\
  105.  
  106.  
  107.  
  108. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  109. // CPrefsDialogDirector::TalkToUser
  110. //
  111. // Purpose: Handle commands for the dialog.
  112. //
  113. // Parameters: none
  114. //_________________________________________________________
  115.  
  116. void CPrefsDialogDirector::TalkToUser(void)
  117. {
  118.  
  119.     long dismiss_command;
  120.     
  121.     BeginModalDialog();
  122.     long dismiss = DoModalDialog(cmdOK);
  123.     
  124.     if (dismiss == cmdOK)
  125.         {
  126.  
  127.         PrefsStruct prefs = gPrefs->prefs;                //  Get the current prefs
  128.  
  129.         CPrefsDialog *dialog = (CPrefsDialog *) itsWindow;            //  Add the new colors
  130.         dialog->background_color_pane->GetPaneColor(&(prefs.background_color));
  131.         dialog->left_eye_color_pane->GetPaneColor(&(prefs.left_eye_color));
  132.         dialog->right_eye_color_pane->GetPaneColor(&(prefs.right_eye_color));
  133.  
  134.         gPrefs->prefs = prefs;                            // update prefs to reflect changes
  135.         
  136.         }
  137.     
  138. }    //=== CPrefsDialogDirector::TalkToUser ===\\
  139.